<script type='text/template' id='variant_autocomplete_stock_template'>

  <label><%= Spree.t(:select_stock) %></label>
  <table class="table table-condensed table-bordered stock-levels no-marginb" data-hook="stock-levels">
    <thead>
      <th><%= Spree.t(:location) %></th>
      <th><%= Spree.t(:count_on_hand) %></th>
      <th width="15%"><%= Spree.t(:quantity) %></th>
      <th class="actions"></th>
    </thead>
    <tbody>
      {{#each variant.stock_items}}
        <tr>
          <td>{{this.stock_location_name}}</td>
          {{#unless ../variant.track_inventory}}
            <td><%= Spree.t(:doesnt_track_inventory) %></td>
            <td>
              <input class="quantity form-control input-sm" id="stock_item_quantity" data-stock-location-id="{{this.stock_location_id}}" type="number" min="1" value="1">
            </td>
            <td class="actions actions-1">
              <button class="btn btn-sm btn-success add_variant with-tip" data-stock-location-id="{{this.stock_location_id}}" title="<%= Spree.t(:add) %>" data-action="add">
                <span class="icon icon-add"></span>
              </button>
            </td>
          {{else}}
            {{#if this.available}}
              <td>
                {{this.count_on_hand}}
                {{#if this.backorderable}} (<%= Spree.t(:backorders_allowed) %>) {{/if}}
              </td>
              <td>
                <input class="quantity form-control input-sm" id="stock_item_quantity" data-stock-location-id="{{this.stock_location_id}}" type="number" min="1" value="1">
              </td>
              <td class="actions actions-1">
                <button class="btn btn-sm btn-success add_variant with-tip" data-stock-location-id="{{this.stock_location_id}}" title="<%= Spree.t(:add) %>" data-action="add">
                  <span class="icon icon-add"></span>
                </button>
              </td>
            {{else}}
              <td><%= Spree.t(:out_of_stock) %></td>
              <td>0</td>
              <td></td>
            {{/if}}
          {{/unless}}
        </tr>
      {{/each}}
    </tbody>
  </table>
</script>
